#include "Heap.h"
#include <malloc.h>


Heap::Heap(void):m_numFree(0)
{
}


Heap::~Heap(void)
{
	for ( int i = 0; i < m_numFree; i++)
		free(m_freeList[i]);
}


void* Heap::allocate(size_t size)
{
	if ( m_numFree)
		return m_freeList[--m_numFree];

	return malloc(size);
}


void Heap::deallocate(void* op)
{
	if ( m_numFree == HEAP_MAX_FREE_LIST)
		free(op);
	else
		m_freeList[m_numFree++] = op;
}